home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form TestForm
- Caption = "TestForm for Customer and Customers objects"
- ClientHeight = 2715
- ClientLeft = 1770
- ClientTop = 3780
- ClientWidth = 6405
- LinkTopic = "Form1"
- PaletteMode = 1 'UseZOrder
- ScaleHeight = 2715
- ScaleWidth = 6405
- WhatsThisHelp = -1 'True
- Begin VB.CommandButton cmdExit
- Caption = "Exit"
- Height = 495
- Left = 4080
- TabIndex = 6
- Top = 2040
- Width = 2175
- End
- Begin VB.CommandButton cmdGetNextCustomers
- Caption = "Get Next Customers"
- Enabled = 0 'False
- Height = 495
- Left = 2160
- TabIndex = 5
- Top = 2040
- Width = 1815
- End
- Begin VB.CommandButton cmdGetFirstCustomer
- Caption = "Get First Customer"
- Enabled = 0 'False
- Height = 495
- Left = 2160
- TabIndex = 4
- Top = 1440
- Width = 1815
- End
- Begin VB.CommandButton cmdLookupByID
- Caption = "Lookup by ID"
- Enabled = 0 'False
- Height = 495
- Left = 2160
- TabIndex = 3
- Top = 840
- Width = 1815
- End
- Begin VB.CommandButton cmdLookupByLastName
- Caption = "Lookup by Last Name"
- Enabled = 0 'False
- Height = 495
- Left = 2160
- TabIndex = 2
- Top = 240
- Width = 1815
- End
- Begin VB.CommandButton cmdReleaseObjects
- Caption = "Release Customer Object"
- Enabled = 0 'False
- Height = 495
- Left = 4080
- TabIndex = 1
- Top = 240
- Width = 2175
- End
- Begin VB.CommandButton cmdCreateObjects
- Caption = "Create Customer Object"
- Height = 495
- Left = 120
- TabIndex = 0
- Top = 240
- Width = 1935
- End
- Attribute VB_Name = "TestForm"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Option Explicit
- Dim myCustomer As ADODB.Recordset
- Dim myCustomers As AWCustomer.Customers
- Private Sub DumpCustomer()
- Dim strDump As String
- Dim NL As String
- On Error GoTo onError
- ' build up string with text description of each property
- NL = Chr(13) + Chr(10)
- strDump = "CustomerID = " & myCustomer.Fields("CustomerID").Value
- strDump = strDump & NL & "CustomerFirstName = " & myCustomer.Fields("CustomerFirstName").Value
- strDump = strDump & NL & "CustomerLastName= " & myCustomer.Fields("CustomerLastName").Value
- strDump = strDump & NL & "BillingAddress= " & myCustomer.Fields("BillingAddress").Value
- strDump = strDump & NL & "City = " & myCustomer.Fields("City").Value
- strDump = strDump & NL & "StateOrProvince = " & myCustomer.Fields("StateOrProvince").Value
- strDump = strDump & NL & "PostalCode = " & myCustomer.Fields("PostalCode").Value
- strDump = strDump & NL & "Country = " & myCustomer.Fields("Country").Value
- strDump = strDump & NL & "PhoneNumber = " & myCustomer.Fields("PhoneNumber").Value
- strDump = strDump & NL & "EmailAddress = " & myCustomer.Fields("EmailAddress").Value
- MsgBox strDump
- ' all went well - return
- Exit Sub
- onError:
- MsgBox "error in TestForm.DumpCustomer"
- End Sub
- Private Sub cmdCreateObjects_Click()
- Set myCustomers = CreateObject("AWCustomer.Customers")
-
- ' now that we have objects it makes sense to enable the other commands
- cmdCreateObjects.Enabled = False
- cmdLookupByLastName.Enabled = True
- cmdLookupByID.Enabled = True
- cmdGetFirstCustomer.Enabled = True
- cmdGetNextCustomers.Enabled = True
- cmdReleaseObjects.Enabled = True
- ' all went well - return
- Exit Sub
-
- End Sub
- Private Sub cmdGetNextCustomers_Click()
- If myCustomer.EOF Then
- MsgBox "All the records have been displayed"
- Else
- DumpCustomer
- myCustomer.MoveNext
- End If
- End Sub
- Private Sub cmdReleaseObjects_Click()
- On Error GoTo onError
- Set myCustomer = Nothing
- ' disable commands that don't make sense without objects
- cmdCreateObjects.Enabled = True
- cmdLookupByLastName.Enabled = False
- cmdLookupByID.Enabled = False
- cmdGetFirstCustomer.Enabled = False
- cmdGetNextCustomers.Enabled = False
- cmdReleaseObjects.Enabled = False
- ' all went well - return
- Exit Sub
- onError:
- MsgBox "error in cmdReleaseObjects"
- End Sub
- Private Sub cmdLookupByLastName_Click()
- Dim vLastName
- On Error GoTo onError
- vLastName = "White"
- Set myCustomer = myCustomers.LookupCustomerByLastName(vLastName)
- MsgBox "LookupByLastName succeeded"
- Exit Sub
- onError:
- MsgBox Err.Number & ": " & Err.Description
- End Sub
- Private Sub cmdLookupByID_Click()
- Dim vID
- vID = 3
- On Error GoTo onError
- Set myCustomer = myCustomers.LookupCustomerByID(vID)
- MsgBox "LookupCustomerByID succeeded"
- DumpCustomer
- ' all went well - return
- Exit Sub
- onError:
- MsgBox "error in cmdLookupByID_Click"
- End Sub
- Private Sub cmdGetFirstCustomer_Click()
- On Error GoTo onError
- myCustomer.MoveFirst
- DumpCustomer
- ' all went well - return
- Exit Sub
- onError:
- MsgBox "error in cmdGetFirstCustomer_Click"
- End Sub
- Private Sub cmdExit_Click()
-
- End
- End Sub
-